<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../public/css/monokai_sublime.min.css">
    <link rel="stylesheet" href="../../public/css/heightlength.css">
    <link rel="stylesheet" href="../../public/css/mxjs.css">
    <link rel="stylesheet" href="../../public/css/prism.css">
    <script src="../../public/js/jquery.js"></script>
    <script src="../../public/js/highlight.min.js"></script>
    <script src="../../public/js/prism.js"></script>
    <script src="../../public/js/clipboard.min.js"></script>

</head>
<body>
<button>点击</button>
<div class="container">
    <div class="jsbg">
        <div class="col-lg-12 mxlength">
            <div class="mx-1">
                <h2>map,set,fillter</h2>

                let newarr= arr.map(Math.sqrt);这样写原理就是下面这样
                <div>
                    var numbers = [65, 44, 12, 4];
                    function multiplyArrayElement(num) {
                    return num * document.getElementById("multiplyWith").value;
                    }
                    function myFunction() {
                    document.getElementById("demo").innerHTML = numbers.map(multiplyArrayElement);
                    }
                </div>
                <p><strong>注意:</strong> IE 11 及更早版本不支持 copyWithin() 方法。这个方法要改变原来的数组</p>
                <p><strong>注意:</strong>arr.entries这个方法返回的是一个迭代，需要遍历</p>
            </div>
        </div>
        <div class="col-lg-12  ">
      <pre class="mScroll">
        <code class="lang-javascript">
                let arr = [
        {name: 1, age: 3},
        {name: 2, age: 4}
    ]
    arr.map(function (a, b, c) {
        console.log(a, 'a')
        console.log(b, 'b')
        console.log(c, 'c')
    })
    var arr = [2, 9, 16, 25];
    let newarr = arr.map(function (item, index, arr) {
        return Math.sqrt(item)
    });
    var arr = [2, 9, 16, 25];
    let newarr = arr.map(Math.sqrt);
    console.log(newarr);
    let obj = [
        {name: '323'},
        {name: '44'}
    ]
    let obj2 = [
        {name: '323'},
        {name: '44'}
    ]
    console.log(obj.concat(obj2))

    //替换第三个个，从0开始到2结束 [0，2）  // ["Banana", "Orange", "Apple", "Banana"]
    var arr = ["Banana", "Orange", "Apple", "Mango"];
    arr.copyWithin(3, 0, 2);

    let arr = [
        {name: '323'},
        {name: '44'}
    ]
    for (let i of arr.entries()) {
        console.log(i)
    }

    //[0,{...}]//[1,{...}]
    const obj = {name: 'xixixi', age: '23'};
    console.log(Object.entries(obj));  // [['name', 'xixixi'], ['age', '23']]

    var ages = [32, 33, 16, 40];

    function checkAdult(age) {
        return age >= 18;
    }
    console.log(ages.every(checkAdult))   //false
  function checkAdult(age) {
        return age >= 18;
    }
    console.log(ages.some(checkAdult))   //同every，单some只能遍历到满足第一个条件的时候停止遍历

            var fruits = ["Banana", "Orange", "Apple", "Mango"];
           console.log(fruits.fill("Runoob",2,4)) //[Banana,Orange,Runoob,Runoob]
        </code>
    </pre>
        </div>
    </div>
</div>
<script>

let str="abcabcdabc";
let arr=str.split("");
let newarr=arr.map((item,index,arr)=>{
    return arr[index]!=arr[index+1]
})
console.log(newarr)
    window.onload = function () {
        var clipboard = new Clipboard('.toolbar-item');
        clipboard.on('success', function (e) {
            console.log(e.text);
        });
        clipboard.on('error', function (e) {
            console.log(e);
        });
        $(".toolbar-item").html("<span>复制</span>")
    }
</script>
</body>
</html>
